import {debounce} from '../utils/index'

/**
 * 防抖装饰器
 * @param wait {number} 间隔时间
 * @param immediate {boolean} 是否立即执行一次
 * @returns
 */
export default function debounceDecorator(wait: number = 200, immediate: boolean = true): MethodDecorator {
  return function (target: object, name: string | symbol, descriptor: TypedPropertyDescriptor<any>) {
    descriptor.value = debounce(descriptor.value, wait, immediate)
  }
}

